package com.ktgj.hotel.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ktgj.common.log.annotation.Log;
import com.ktgj.common.log.enums.BusinessType;
import com.ktgj.common.security.annotation.PreAuthorize;
import com.ktgj.hotel.domain.HotelRoomPrice;
import com.ktgj.hotel.service.IHotelRoomPriceService;
import com.ktgj.common.core.web.controller.BaseController;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.common.core.utils.poi.ExcelUtil;
import com.ktgj.common.core.web.page.TableDataInfo;

/**
 * 酒店房型价格Controller
 * 
 * @author ruoyi
 * @date 2022-08-25
 */
@RestController
@RequestMapping("/price")
public class HotelRoomPriceController extends BaseController
{
    @Autowired
    private IHotelRoomPriceService hotelRoomPriceService;

    /**
     * 查询酒店房型价格列表
     */
    @PreAuthorize(hasPermi = "system:price:list")
    @GetMapping("/list")
    public TableDataInfo list(HotelRoomPrice hotelRoomPrice)
    {
        startPage();
        List<HotelRoomPrice> list = hotelRoomPriceService.selectHotelRoomPriceList(hotelRoomPrice);
        return getDataTable(list);
    }

    /**
     * 导出酒店房型价格列表
     */
    @PreAuthorize(hasPermi = "system:price:export")
    @Log(title = "酒店房型价格", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HotelRoomPrice hotelRoomPrice) throws IOException
    {
        List<HotelRoomPrice> list = hotelRoomPriceService.selectHotelRoomPriceList(hotelRoomPrice);
        ExcelUtil<HotelRoomPrice> util = new ExcelUtil<HotelRoomPrice>(HotelRoomPrice.class);
        util.exportExcel(response, list, "酒店房型价格数据");
    }

    /**
     * 获取酒店房型价格详细信息
     */
    @PreAuthorize(hasPermi = "system:price:query")
    @GetMapping(value = "/{roomPriceId}")
    public AjaxResult getInfo(@PathVariable("roomPriceId") Long roomPriceId)
    {
        return AjaxResult.success(hotelRoomPriceService.selectHotelRoomPriceById(roomPriceId));
    }

    /**
     * 新增酒店房型价格
     */
    @PreAuthorize(hasPermi = "system:price:add")
    @Log(title = "酒店房型价格", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HotelRoomPrice hotelRoomPrice)
    {
        return toAjax(hotelRoomPriceService.insertHotelRoomPrice(hotelRoomPrice));
    }

    /**
     * 修改酒店房型价格
     */
    @PreAuthorize(hasPermi = "system:price:edit")
    @Log(title = "酒店房型价格", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HotelRoomPrice hotelRoomPrice)
    {
        return toAjax(hotelRoomPriceService.updateHotelRoomPrice(hotelRoomPrice));
    }

    /**
     * 删除酒店房型价格
     */
    @PreAuthorize(hasPermi = "system:price:remove")
    @Log(title = "酒店房型价格", businessType = BusinessType.DELETE)
	@DeleteMapping("/{roomPriceIds}")
    public AjaxResult remove(@PathVariable Long[] roomPriceIds)
    {
        return toAjax(hotelRoomPriceService.deleteHotelRoomPriceByIds(roomPriceIds));
    }
}
